home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Trusted Irix /B 4.0.4
/
Trusted-Irix B-4.0.1.iso
/
dist
/
eoe1.idb
/
etc
/
init.d
/
network.z
/
network
Wrap
Text File
|
1992-04-03
|
21KB
|
690 lines
#! /bin/sh
#Tag 0x00000f00
# Initialize/Shutdown the standard and optional network software.
#
# $Revision: 4.13 $
#
# If the IP address for this host is the default 192.0.2.1 Internet test
# address, the software is configured for loopback (standalone) mode.
# An Internet address other than the default must be chosen in order to
# configure the network properly. See the "Network Administration" chapter
# in the Network Communications Guide or details on selecting an address.
#
# NOTE: Defaults for network interface names and addresses can be changed by
# editting /etc/config/netif.options. Therefore, you don't need to edit
# this file.
#
# A daemon or subsystem is enabled if its configuration flag in the
# /etc/config directory in the "on" state. /etc/chkconfig is used
# to test a flag's state (see chkconfig(1M) for details). If the flag
# file is missing, the flag is considered off.
#
# Flag Action if On
# network Allow incoming & outgoing traffic. This flag can be
# set off if you need to isolate the machine from
# network without removing cables.
# verbose Print name of daemons as they are started & other info
# gated Start Cornell routing daemon instead of BSD routed
# mrouted Start Stanford IP multicast routing daemon
# (Useful only on gateways)
# named Start 4.3BSD Internet domain name server
# rwhod Start 4.3BSD rwho daemon
# snmpd Start Simple Network Management Protocol daemon
# timed Start 4.3BSD time synchronization daemon
# timeslave Start SGI time synchronization daemon
# hypernet Initialize HyperNET controller and routes
# routed Start 4.3BSD RIP routing daemon
# rtnetd Initialize preemptable networking for real-time use
# ipfilterd Enable SGI IP Packet Filtering daemon
#
# The following flags are installed only in the optional products:
#
# nfs Start NFS daemons, mount NFS filesystems
# automount Start the NFS automounter daemon
# lockd Start the NFS lock and status daemons
# pcnfsd Start the PC-NFS server daemon
# rarpd Start the Reverse ARP daemon
# yp Enable NIS, start ypbind daemon
# ypserv If yp is on, become a NIS server
# ypmaster If yp is on, become the NIS master; start passwd server
# (ypserv should be on, too)
# 4DDN Initialize 4DDN (DECnet connectivity) software
#
# Site-dependent options for daemons belong in "options" files in /etc/config.
# Certain daemons require options so their options file must contain valid
# information. See the daemon's manual page in section 1M for details on
# valid options. If this host is on networks that use subnetting, add the
# appropriate 'netmask' to the ifconfig-*.options files (see ifconfig(1M) for
# details on netmasks).
#
# File Status
# automount.options optional
# biod.options optional
# gated.options optional
# ifconfig-1.options optional (for primary network interface)
# ifconfig-2.options optional (for 1st gateway network interface)
# ifconfig-3.options optional (for 2nd gateway network interface)
# ifconfig-4.options optional (for 3rd gateway network interface)
# ifconfig-hy.options optional (for HyperNET interface)
# inetd.options optional
# lockd.options optional
# mrouted.options optional
# named.options optional
# netif.options optional (to select different primary &
# gateway interfaces, etc.)
# nfsd.options optional
# portmap.options optional
# rarpd.options optional
# routed.options optional
# rpc.passwd.options optional
# rtnetd.options optional
# rwhod.options optional
# snmpd.options optional
# timed.options optional
# timeslave.options required
# ypbind.options optional
# ypserv.options optional
#
# In addition, site-dependent configuration commands to add static routes
# and publish arp entries should be put in a separate shell script called
# /etc/init.d/network.local. Make symbolic links in /etc/rc0.d and
# /etc/rc2.d to this file to have it called during system startup
# and shutdown:
# ln -s /etc/init.d/network.local /etc/rc0.d/K39network # before network
# ln -s /etc/init.d/network.local /etc/rc2.d/S31network # after network
# The script is called with one argument ("start" or "stop").
#
#
# Copyright 1988-1991 Silicon Graphics, Inc.
# All rights reserved.
#
# This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
# the contents of this file may not be disclosed to third parties, copied or
# duplicated in any form, in whole or in part, without the prior written
# permission of Silicon Graphics, Inc.
#
# RESTRICTED RIGHTS LEGEND:
# Use, duplication or disclosure by the Government is subject to restrictions
# as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
# and Computer Software clause at DFARS 252.227-7013, and/or in similar or
# successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
# rights reserved under the Copyright Laws of the United States.
CONFIG=/etc/config
IS_ON=/etc/chkconfig
# The verbose flag controls the printing of the names of daemons as they
# are started and the printing of NFS-mounted filesystem names as they are
# mounted and unmounted.
if $IS_ON verbose ; then
ECHO=echo
VERBOSE=-v
else # For a quiet startup and shutdown
ECHO=:
VERBOSE=
fi
PATH=$PATH:/usr/etc/yp:.
NFS=/usr/etc
YPDOMFILE=/usr/etc/yp/ypdomain
YPSETDOM=/usr/bin/domainname
IFCONFIG=/usr/etc/ifconfig
ROUTE=/usr/etc/route
localhost=127.1 # definition of 'localhost' in /etc/hosts
nfs_on () {
$IS_ON nfs && test -x /etc/havenfs && /etc/havenfs
return
}
configure () {
# args: $1 = interface name, $2 = address, $3 = ifconfig options filename
# $4 = "primary" or ""
$ECHO "Configuring $1 as $2"
case "$1" {
ipg? | imf?)
if /usr/etc/smtconfig $1 $2 $4 `cat $3 2> /dev/null` 2> /dev/null
then :
else
$IFCONFIG $1 inet $2 $4 `cat $3 2> /dev/null` 2> /dev/null
fi
;;
*)
$IFCONFIG $1 inet $2 $4 `cat $3 2> /dev/null` 2> /dev/null
;;
}
if test $? -ne 0 ; then
echo "\n*** WARNING: failed to configure $1 as $2\n"
return 1
fi
return 0
}
if test "`/etc/nvram diskless 2> /dev/null`" -eq 1; then
DLMNTOPTS='-b /,/share,/swap'
RFLUSHFLAG=-fq
else
RFLUSHFLAG=-Fq
fi
case "$1" in
'start')
# Check the Internet address to decide how to configure things.
HOSTNAME=`hostname`
netstate="loopback"
if test -x /usr/bsd/hostid; then
if hostid -h $HOSTNAME; then
if test "`hostid`" = "0xc0000201"; then
echo "*** $HOSTNAME's Internet address is the default: \c"
elif $IS_ON network; then
netstate="ok"
fi
else
hostid 0
echo \
"*** Can't find $HOSTNAME's Internet address in /etc/hosts:\n*** \c"
fi
elif $IS_ON network; then
netstate="ok" # assume it's ok
fi
# The following tests determine the names and addresses of the primary
# and gateway interfaces for typical configurtations, where
# Name = interface name reported by "/usr/etc/netstat -i".
# Address = hostname in /etc/hosts or an IP address in dot notation.
#
# Edit /etc/config/netif.options to override values computed below.
#
# Note: If this host has more than 2 interfaces, you must edit
# /etc/config/netif.options to set if3name & if3addr, and
# if4name & if4addr, as appropriate.
# Suggested addresses for the primary and gateway interfaces.
if1addr=$HOSTNAME
if2addr=gate-$HOSTNAME
if $IFCONFIG ipg0 >/dev/null 2>&1; then # FDDI
# If FDDI is present, make it the primary interface and
# Ethernet the gateway interface.
if1name=ipg0
if $IFCONFIG et0 >/dev/null 2>&1; then # POWER Series systems
if2name=et0
elif $IFCONFIG ec0 >/dev/null 2>&1; then # Personal Iris series
if2name=ec0
elif $IFCONFIG fxp0 >/dev/null 2>&1; then # Professional IRIS
if2name=fxp0 # (4D/50-4D/85)
elif $IFCONFIG enp0 >/dev/null 2>&1; then # ditto
if2name=enp0
fi
elif $IFCONFIG et0 >/dev/null 2>&1; then
if1name=et0
if $IFCONFIG et1 >/dev/null 2>&1; then
if2name=et1
elif $IFCONFIG fxp0 >/dev/null 2>&1; then
if2name=fxp0
else
if2name=enp0
fi
elif $IFCONFIG ec0 >/dev/null 2>&1; then
if1name=ec0
if $IFCONFIG fxp0 >/dev/null 2>&1; then
if2name=fxp0
else
if2name=enp0
fi
elif $IFCONFIG fxp0 >/dev/null 2>&1; then
if1name=fxp0
if $IFCONFIG fxp1 >/dev/null 2>&1; then
if2name=fxp1
else
if2name=enp0
fi
elif $IFCONFIG enp0 >/dev/null 2>&1; then
if1name=enp0
if2name=enp1
fi
# Obtain site-dependent values for if1name,if1addr,...,if4name,if4addr.
if test -s $CONFIG/netif.options; then
. $CONFIG/netif.options
fi
# Flush all old routes iff not diskless
$ROUTE $RFLUSHFLAG >/dev/null 2>&1
# Configure the network interfaces.
if test "$netstate" = "ok"; then
if configure $if1name $if1addr $CONFIG/ifconfig-1.options primary;
then :
else
echo "*** WARNING: Can't access primary interface: \c"
netstate="loopback"
fi
elif test "$netstate" != "loopback"; then
netstate="loopback"
fi
if test $netstate = "loopback"; then
echo "Using standalone network mode."
if test "$if1name" != ""; then
$IFCONFIG $if1name inet $if1addr 2>/dev/null
$IFCONFIG $if1name down 2>/dev/null
fi
$IFCONFIG lo0 $localhost
$ROUTE -q delete net $if1addr $if1addr >/dev/null 2>&1
$ROUTE -q add 224.0.0.0 $localhost 0 >/dev/null 2>&1
else
# IP Packet Filtering daemon.
#
# It should be started before any gateway interface is configured "up"
# in order to guarantee that all inbound packets are filtered.
if $IS_ON ipfilterd && test -x /usr/etc/ipfilterd; then
/etc/killall ipfilterd
/usr/etc/ipfilterd
$ECHO "Starting ipfilterd."
fi
# Initialize other boards if this host is a gateway (no harm if
# they are missing).
if test "$if2name" != "" && $IFCONFIG $if2name >/dev/null 2>&1; then
configure $if2name $if2addr $CONFIG/ifconfig-2.options
fi
# Initialize 3rd & 4th boards if names are defined in netif.options.
if test "$if3name" != "" && $IFCONFIG $if3name >/dev/null 2>&1; then
configure $if3name $if3addr $CONFIG/ifconfig-3.options
fi
if test "$if4name" != "" && $IFCONFIG $if4name >/dev/null 2>&1; then
configure $if4name $if4addr $CONFIG/ifconfig-4.options
fi
# If this IRIS has more than 4 network interfaces,
# for each interface, copy the "configure" line above,
# adjust the interface number and add appropriate ifXname
# and ifXaddr variables in the /etc/config/netif.options file.
# Initialize the HyperNET interface.
if $IS_ON hypernet && $IFCONFIG hy0 >/dev/null 2>&1 &&
configure hy0 $HOSTNAME-hy $CONFIG/ifconfig-hy.options ; then
/usr/etc/hyroute hy0 -s /usr/etc/hyroute.conf
fi
# Initialize the loop-back interface
$IFCONFIG lo0 $localhost
fi
# Send traffic for this host through lo0 for better performance
HOSTRESORDER=local $ROUTE -q add host $if1addr $localhost 0 >/dev/null 2>&1
$ECHO "Network daemons:\c"
if test -x /usr/etc/rtnetd; then
# Always start on multiprocessors for better throughput
if $IS_ON rtnetd || test `mpadmin -u | wc -l` -gt 1; then
/usr/etc/rtnetd `cat $CONFIG/rtnetd.options 2> /dev/null`
$ECHO " rtnetd\c"
fi
fi
/etc/killall gated routed mrouted portmap named
if test $netstate = "ok" ; then
# Start either gated (the fancy routing daemon) or routed.
#
# Note: gated and mrouted use configuration files in /usr/etc.
# See gated(1M) and mrouted(1M) for details on their setup.
if $IS_ON gated && test -x /usr/etc/gated ; then
/usr/etc/gated `cat $CONFIG/gated.options 2> /dev/null` &
$ECHO " gated\c"
elif $IS_ON routed && test -x /usr/etc/routed ; then
# Useful option:
# -q = "quiet": don't act as router if > 1 interface.
# See routed(1M) for other options.
/usr/etc/routed `cat $CONFIG/routed.options 2> /dev/null` &
$ECHO " routed\c"
fi
# Set the default route for all IP multicast packets to the
# primary interface.
HOSTRESORDER=local $ROUTE -q add 224.0.0.0 $if1addr 0 >/dev/null 2>&1
if $IS_ON mrouted && test -x /usr/etc/mrouted; then
/usr/etc/mrouted `cat $CONFIG/mrouted.options 2> /dev/null` &
$ECHO " mrouted\c"
fi
fi
if test -x /usr/etc/portmap; then
/usr/etc/portmap `cat $CONFIG/portmap.options 2> /dev/null` &
$ECHO " portmap\c"
fi
# Berkeley Internet Name Domain server:
#
# It has to be started before NIS and NFS so they can use hostnames
# not in /etc/hosts.
if $IS_ON named && test -x /usr/etc/named; then
/usr/etc/named `cat $CONFIG/named.options 2> /dev/null` < /dev/null
$ECHO " named\c"
fi
$ECHO "."
# Define the NIS domain name.
if test -x $YPSETDOM; then
# The ypdomain file is needed only if NIS domain != Internet domain.
YPDOMAIN=`cat $YPDOMFILE 2> /dev/null`
if test ! "$YPDOMAIN" ; then
# Extract the domain from the hostname.
YPDOMAIN=`echo $HOSTNAME | sed -e 's/[^.]*\.\(.*\)/\1/'`
if test "$YPDOMAIN" = "$HOSTNAME"; then
# Hostname doesn't contain domain.
YPDOMAIN=""
fi
fi
# Set the domain even if "yp" is not "on" so ypbind can be
# started by hand later.
if test "$YPDOMAIN"; then
$YPSETDOM $YPDOMAIN
fi
fi
# Fire up NIS daemons.
if test $netstate = "ok" && $IS_ON yp ; then
if test ! "$YPDOMAIN" ; then
echo "\n*** WARNING: Can't start NIS -- domain name not defined."
echo "*** Edit $YPDOMFILE to contain your domain name and reboot.\n"
else
YPDBDIR=$NFS/yp/$YPDOMAIN
$YPSETDOM $YPDOMAIN
/etc/killall ypbind ypserv rpc.passwd
$ECHO "NIS domain: $YPDOMAIN"
$ECHO "NIS daemons:\c"
# NIS type: Must run:
# master server ypserv, rpc.passwd, ypbind
# slave server ypserv, ypbind
# client ypbind
# Make this host a NIS server.
if $IS_ON ypserv && test -x $NFS/ypserv; then
if test -d $YPDBDIR ; then
# Useful option:
# -i = get inter-domain host info from named
$NFS/ypserv `cat $CONFIG/ypserv.options 2> /dev/null` &
$ECHO " ypserv\c"
else
echo "\n*** WARNING: ypserv not started -- $YPDBDIR database dir. missing"
fi
fi
# Make this host the NIS master server for the passwd file.
if $IS_ON ypmaster && test -x $NFS/rpc.passwd; then
# A reasonable alternate password file is '/etc/passwd.yp'
# This allows the valid accounts on the NIS master
# to not be all valid accounts in the network.
PASSWD=`cat $CONFIG/rpc.passwd.options 2> /dev/null`
$NFS/rpc.passwd ${PASSWD:=/etc/passwd} -m passwd &
$ECHO " rpc.passwd\c"
fi
# ypbind allows NIS servers and clients to use NIS services.
if test -x $NFS/ypbind; then
$NFS/ypbind `cat $CONFIG/ypbind.options 2> /dev/null` &
$ECHO " ypbind\c"
sleep 2
fi
$ECHO "."
fi
fi
# Fire up NFS daemons if the kernel supports NFS and the daemons are
# present and executable. Also mount the NFS filesystems in /etc/fstab.
if test "$netstate" = "ok" && nfs_on ; then
# Clear this host from the client list (/etc/rmtab) of all
# servers on the network. Remove any stale exports from
# the current exports list (/etc/xtab).
2>&1 umount -at nfs ${DLMNTOPTS} > /dev/null
2>&1 $NFS/exportfs -au > /dev/null
$ECHO "NFS daemons:\c"
/etc/killall nfsd biod
# NFS server daemons
if test -x $NFS/nfsd; then
NNFSD=`cat $CONFIG/nfsd.options 2> /dev/null`
$NFS/nfsd ${NNFSD:=4}; $ECHO " nfsd\c"
fi
# NFS client bio daemons
if test -x $NFS/biod; then
NBIOD=`cat $CONFIG/biod.options 2> /dev/null`
$NFS/biod ${NBIOD:=4}; $ECHO " biod\c"
fi
$ECHO "."
/etc/mount $VERBOSE -at nfs ${DLMNTOPTS}
$NFS/exportfs -a $VERBOSE
if $IS_ON automount || $IS_ON lockd || $IS_ON pcnfsd ; then
$ECHO "Other NFS daemons:\c"
# Start the NFS automounter daemon
if $IS_ON automount && test -x $NFS/automount ; then
if /etc/killall -TERM automount ; then
sleep 2 # Allow it some time to clean up.
fi
$NFS/automount \
`cat $CONFIG/automount.options 2> /dev/null` >/dev/null 2>&1
$ECHO " automount\c"
fi
# Start the NFS lock and status daemons
if $IS_ON lockd ; then
if test -x $NFS/rpc.statd ; then
/etc/killall rpc.statd
$NFS/rpc.statd; $ECHO " statd\c"
fi
if test -x $NFS/rpc.lockd ; then
/etc/killall rpc.lockd
$NFS/rpc.lockd `cat $CONFIG/lockd.options 2> /dev/null` &
$ECHO " lockd\c"
fi
fi
# PC-NFS server daemon
if $IS_ON pcnfsd && test -x $NFS/pcnfsd ; then
$NFS/pcnfsd; $ECHO " pcnfsd\c"
fi
$ECHO "."
fi
fi
# Daemons started below may reside on NFS filesystems.
$ECHO "Internet daemons:\c"
/etc/killall inetd timed timeslave rarpd rwhod snmpd
# Internet super-server:
#
# Invokes servers in /usr/etc/inetd.conf. Use the inetd.options file
# to specify a different configuration file.
if test -x /usr/etc/inetd; then
/usr/etc/inetd `cat $CONFIG/inetd.options 2> /dev/null` < /dev/null
$ECHO " inetd\c"
fi
# Time synchronization servers:
# timed keeps time consistent among machines on a local network.
# timeslave tracks changes made by a master time keeper.
#
# Timed can be given options in $CONFIG/timed.options, detailed
# in the timed(1M) man page.
#
# Timeslave requires the name of host to follow (-H hostname)
# or the name of clock device that listens to WWV (-C /dev/ttyXX).
# Other options are listed in the man page.
if $IS_ON timed && test $netstate = "ok" -a -x /usr/etc/timed ; then
/usr/etc/timed -M `cat $CONFIG/timed.options 2> /dev/null` &
$ECHO " timed\c"
fi
if $IS_ON timeslave && test -x /usr/etc/timeslave ; then
if test -s $CONFIG/timeslave.options ; then
/usr/etc/timeslave `cat $CONFIG/timeslave.options` &
$ECHO " timeslave\c"
else
echo "\n*** WARNING: timeslave not started -- options missing"
echo "*** Add them to $CONFIG/timeslave.options and reboot\n"
fi
fi
# RARPD: Reverse ARP daemon.
#
# RARP is used by Sun diskless clients to discover their Internet
# addresses, given their Ethernet addresses.
if $IS_ON rarpd && test $netstate = "ok" -a -x /usr/etc/rarpd ; then
/usr/etc/rarpd `cat $CONFIG/rarpd.options 2> /dev/null` &
$ECHO " rarpd\c"
fi
# Rwhod: 4.3BSD's system status daemon.
#
# Important: if there are lots of hosts on the network,
# DO NOT run rwhod because it can saturate the network.
if $IS_ON rwhod && test $netstate = "ok" -a -x /usr/etc/rwhod; then
if test ! -d /usr/spool/rwho; then
mkdir /usr/spool/rwho
fi
/usr/etc/rwhod `cat $CONFIG/rwhod.options 2> /dev/null`
$ECHO " rwhod\c"
fi
# snmpd: Simple Network Management Protocol daemon.
#
# SNMP (RFC 1157) is used to query MIB variables (RFC 1158)
# from a network entity.
if $IS_ON snmpd && test $netstate = "ok" -a -x /usr/etc/snmpd; then
/usr/etc/snmpd `cat $CONFIG/snmpd.options 2> /dev/null`
$ECHO " snmpd\c"
fi
$ECHO "."
if $IS_ON 4DDN && test $netstate = "ok" -a -x /usr/etc/dn/dnstart.sh; then
/etc/killall -TERM dnserver
/usr/etc/dn/dnstart.sh $VERBOSE
fi
;;
'stop')
# Servers that might start shells.
USERS='rlogind rexecd rshd ftpd telnetd sethostd dnserver'
# The following servers should be killed immediately.
EDAEMONS='inetd bootp tftpd timed timeslave rarpd rwhod talkd fingerd
automount rpc.mountd rpc.lockd rpc.statd rpc.bootparamd
rpc.rexd rpc.rstatd rpc.rusersd rpc.rwalld rpc.ypupdated
fal smtd snmpd'
# Remote daemons
RDAEMONS='ypserv ypbind rpc.passwd nfsd biod pcnfsd rpc.rquotad
named gated routed mrouted'
# These daemons should be kept alive until the last minute.
LDAEMONS='portmap slip ipfilterd'
# Kill (probable) shell process groups first
/etc/killall -g 1 $USERS
sleep 1
/etc/killall -TERM $EDAEMONS $USERS
sleep 1
/etc/umount $VERBOSE -kt nfs ${DLMNTOPTS}
/etc/killall -TERM $RDAEMONS
sleep 1
# Unexport any exported NFS filesystems (assumes netstate = ok)
# Do this after killing the NFS demons so that clients do not
# suffer errors on their read(2) requests, if they have hard-mounted
# things. /usr may not be mounted, so you must check to see
# that exportfs is available.
if nfs_on && test -x $NFS/exportfs; then
$NFS/exportfs -au $VERBOSE
fi
# Blow away any background mounts and the broadcast umount since
# the network will be shut down soon.
/etc/killall mount umount $USERS $EDAEMONS $RDAEMONS $LDAEMONS rtnetd
# Shutdown FDDI to turn off the optical bypasses and cleanly take
# the system out of the ring.
for num in 0 1 2 3 ; do
$IFCONFIG ipg$num down 2> /dev/null
done
;;
*)
echo "usage: $0 {start|stop}"
;;
esac
# DECnet is a trademark of Digital Equipment Corp.
# NFS is a trademark of Sun Microsystems, Inc.